package top.lishuoboy.springmvc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 注意:这里我们先导入controlLer接口
 *
 * @author lishuoboy
 */
@Slf4j
public class HelloController implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
        log.info("HelloController 默认模板引擎");
        // ModelAndView 模型和视图
        ModelAndView mv = new ModelAndView();
        // 封装对象Model，放在 ModelAndView中。
        mv.addObject("msg", "HelloSpringMVC!");
        // 封装视图View，放在 ModelAndView中。
        mv.setViewName("hello"); // : /WEB-INF/jsp/hello.jsp
        return mv;
    }

}
